package br.com.android.aluno.adapters;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.com.android.aluno.model.Aluno;
import br.com.android.aluno.view.R;

public class ListAdapterAluno extends BaseAdapter {

	private Context context;
	private List<Aluno> alunos;
	
	public ListAdapterAluno(Context context, List<Aluno> alunos) {
		this.context = context;
		this.alunos = alunos;
	}
	
	@Override
	public int getCount() {
		return alunos.size();
	}

	@Override
	public Object getItem(int position) {
		return alunos.get(position);
	}

	@Override
	public long getItemId(int id) {
		return id;
	}

	public List<Aluno> getAlunos() {
		return alunos;
	}

	@Override
	public View getView(int posicao, View contentView, ViewGroup parent) {
		
		Aluno aluno = alunos.get(posicao);
		
		LayoutInflater inflater = (LayoutInflater) 
			context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View view = inflater.inflate(R.layout.adapter_aluno_item, null);		
		TextView tv = (TextView) view.findViewById(R.id.adapter_aluno_item_tvItem);
		
		tv.setText(aluno.getNome());
		
		return view;
	}

}
